<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="__ADMIN__css/font.css">
    <link rel="stylesheet" href="__ADMIN__css/xadmin.css">
    <script type="text/javascript" src="__ADMIN__js/jq.js"></script>
    <script type="text/javascript" src="__ADMIN__lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="__ADMIN__js/xadmin.js"></script>
    {include file='public/ueditor'}
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="__ADMIN__html5.min.js"></script>
    <script src="__ADMIN__respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="x-body">
    <form class="layui-form">
        <div class="layui-form-item">
            <label for="link_name" class="layui-form-label">
                <span class="x-red">*</span>链接名称
            </label>
            <div class="layui-input-inline">
                <input style="width: 300px"    placeholder=""  value="{$link.link_name}"  type="text" id="link_name" name="link_name"  autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red"></span>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="link_href" class="layui-form-label">
                <span class="x-red">*</span>链接地址
            </label>
            <div class="layui-input-inline">
                <input  style="width: 300px"  placeholder="http://" value="{$link.link_href}"   type="text" id="link_href" name="link_href"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="link_href" class="layui-form-label">
                <span class="x-red">*</span>打开方式
            </label>
            <div class="layui-input-inline">
                    <input type="radio" name="open_type" value="1" title="新页面" {if $link.open_type == 1} checked {/if}><div class="layui-unselect layui-form-radio layui-form-radioed"><i class="layui-anim layui-icon"></i><div>新页面</div></div>
                    <input type="radio" name="open_type" value="2" title="本页面" {if $link.open_type == 2} checked {/if}><div class="layui-unselect layui-form-radio"><i class="layui-anim layui-icon"></i><div>本页面</div></div>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="link_href" class="layui-form-label">
                <span class="x-red">*</span>no_follow
            </label>
            <div class="layui-input-inline">
                <input type="radio" name="no_follow" value="1" title="是" {if $link.no_follow == 1} checked {/if}><div class="layui-unselect layui-form-radio layui-form-radioed"><i class="layui-anim layui-icon"></i><div>是</div></div>
                <input type="radio" name="no_follow" value="0" title="否" {if $link.no_follow == 0} checked {/if}><div class="layui-unselect layui-form-radio"><i class="layui-anim layui-icon"></i><div>否</div></div>
            </div>
        </div>
</div>
    <input type="hidden" name="id" value="{$link.id}">
<div class="layui-form-item">
    <label for="L_repass" class="layui-form-label">
    </label>
    <button type="button"  class="layui-btn" lay-filter="add" lay-submit="">
        增加
    </button>
</div>
</form>
</div>
<script>
    layui.use(['form','layer'], function(){
        $ = layui.jquery;
        var form = layui.form
            ,layer = layui.layer;
        //监听提交
        form.on('submit(add)', function(data){
            //console.log(data);
            var cateData = $('.layui-form').serialize();
            $.ajax({
                type:'post',
                data:cateData,
                dataType:'json',
                url:"{:url('admin/link/editLink')}",
                success:function (data) {
                    if (data.code == 0){
                        layer.alert(data.message, {icon: 6},function () {
                            // 获得frame索引
                            var index = parent.layer.getFrameIndex(window.name);
                            //关闭当前frame
                            parent.layer.close(index);
                            return false;
                        });
                    }else{
                        layer.alert(data.message, {icon: 5});
                        return false;
                    }
                }
            })
        });
    });

</script>
</body>

</html>